<template>
  <view class="dly">
    <view class="dlq">
      <text class="title">登录</text>
      <view class="input-item">
        <input type="text" placeholder="请输入用户名" v-model="username" />
      </view>
      <view class="input-item">
        <input type="password" placeholder="请输入密码" v-model="password" />
      </view>
      <button class="dlan" @click="login">登录</button>
      <navigator url="/pages/zhuce/zhuce" class="zclj">没有账号？去注册</navigator>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      username: '',
      password: ''
    }
  },
  methods: {
    login() {
      if (!this.username || !this.password) {
        uni.showToast({
          title: '账号或密码不能为空',
          icon: 'none'
        });
        return;
      }
      const correctUser = 'tkw';
      const correctPwd = '056';

      if (this.username === correctUser && this.password === correctPwd) {
        uni.showToast({
          title: '登录成功',
          icon: 'success'
        });
        setTimeout(() => {
          uni.switchTab({
            url: "/pages/geren/geren"
          });
        }, 1000);
      } else {
        uni.showToast({
          title: '账号或密码错误',
          icon: 'none'
        });
      }
    }
  }
}
</script>

<style>

</style>